package demo2;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-08-11
 * Time: 16:33
 */
public class TestDemo1 {

    public static void main(String[] args) {
        //创建一个固定大小的线程池,控制并发线程数量,超出的线程数会在队列中等待
        ExecutorService threadPool = Executors.newFixedThreadPool(10);
        threadPool.submit(new Runnable() {
            @Override
            public void run() {
                System.out.println("你好我是submit执行的");
            }
        });
        threadPool.execute(new Runnable() {
            @Override
            public void run() {
                System.out.println("你好我是execute执行的");
            }
        });

    }

}
